import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/common'
import { OrderService } from './order.service'
import { AuthGuard } from '../common/guard/auth.guard'
import { ApiOperation, ApiTags } from '@nestjs/swagger'

@ApiTags('订单')
@Controller('order')
@UseGuards(AuthGuard)
export class OrderController {
  constructor(private readonly orderService: OrderService) {}

  // 删除订单
  @ApiOperation({ summary: '删除订单' })
  @Delete(':id')
  del(@Param('id') id) {
    return this.orderService.del(id)
  }

  // 添加订单
  @ApiOperation({ summary: '添加订单' })
  @Post()
  save(@Body() body) {
    return this.orderService.save(body)
  }

  // 查询订单
  @ApiOperation({ summary: '查询订单' })
  @Get()
  queryAll(@Body() body) {
    return this.orderService.queryAll(body)
  }

  // 支付
  @ApiOperation({ summary: '支付' })
  @Post('pay')
  pay(@Body('id') id) {
    return this.orderService.pay(id)
  }

  // 取消订单
  @ApiOperation({ summary: '取消订单' })
  @Post('pay')
  cancel(@Body('id') id) {
    return this.orderService.cancel(id)
  }
}
